#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
  char title[100];
  char author[100];
  int y, m, d;
  double p;
} book;

book b[1000];

int cmp(const void *a, const void *b) {
  const book *book_a = (const book *)a;
  const book *book_b = (const book *)b;

  if (book_a->p < book_b->p) {
    return -1; // a < b
  } else if (book_a->p > book_b->p) {
    return 1; // a > b
  } else {
    return 0; // a == b
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char inp = getchar();
    inp = getchar();
    int j = 0;
    while (inp != '\n') {
      b[i].title[j++] = inp;
      inp = getchar();
    }
    inp = getchar();

    j = 0;
    while (inp != '\n') {
      b[i].author[j++] = inp;
      inp = getchar();
    }
    scanf("%d%d%d%lf", &b[i].y, &b[i].m, &b[i].d, &b[i].p);
  }
  qsort(b, n, sizeof(b[0]), cmp);
  printf("Title                                    Author                    "
         "Publish Date    Price     \n");
  for (int i = 0; i < n; i++) {
    printf("%-40s %-25s %d-%02d-%02d      %-10.2lf\n", b[i].title, b[i].author,
           b[i].y, b[i].m, b[i].d, b[i].p);
  }
}